Creating Android Applications: Develop and Design (Chris Chae's Library) by Chris Haseman

Creating Android Applications: Develop and Design (Chris Chae's Library) by Chris Haseman

Author:Chris Haseman
Language: eng
Format: epub, mobi
Publisher: Peachpit Press
Published: 2012-06-16T16:00:00+00:00


The Cleanup

At this point, you’ve created the cache file, retrieved it from the web, and written it to the aforementioned cache file. It’s time to notify anyone who might be listening that the image is available. Here’s the contents of the notifyFinished method that will tell the system both that the image is finished and where to get it.

public static final String TRANSACTION_DONE =

"com.haseman.TRANSACTION_DONE";

private void notifyFinished(String location, String remoteUrl){

Intent i = new Intent(TRANSACTION_DONE);

i.putExtra("location", location);

i.putExtra("url", remoteUrl);

ImageIntentService.this.sendBroadcast(i);

}

Anyone listening for the broadcast intent com.haseman.TRANSACTION_DONE will be notified that an image download has finished. They will be able to pull both the URL (so they can tell if it was an image it actually requested) and the location of the cached file.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.